[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
ldiv() Divide Two Longs
#include <stdlib.h>
ldiv_t ldiv(numer,denom);
long numer;
long denom;
ldiv() divides two longs, the numerator 'numer' and the denominator
'denom'. The result is returned in the structure ldiv_t which is
defined in <stdlib.h>:
typdef struct {
long quot; /* quotient */
long rem; /* remainder */
} ldiv_t;
Returns: The structure div_t whose elements are the result of
the divide performed: the quotient 'quot' and the
remainder 'rem'.
-------------------------------- Example ---------------------------------
The following statements divide two longs and print the result.
#include <stdlib.h>
main()
{
ldiv_t rslt;
long num = 32000, den = 512;
rslt = ldiv(num,den);
printf("%ld div %ld = %ld",num,den,rslt.quot);
if (rslt.rem != 0)
printf(", remainder %ld\n",rslt.rem);
}
See Also:
div()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson